From: Giovanni Campagna Date: Sat, 16 Feb 2013 02:50:28 +0000 (+0100) Subject: Use the right conversion from cairo to GdkPixbuf X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~4841 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=9b9f33bc8be1f1a97a68d12eeeb9b85a3f36ce38;p=gnome-shell.git Use the right conversion from cairo to GdkPixbuf GdkPixbuf is stored in memory as individual bytes, in strict red-green-blue-alpha order, while cairo image surfaces are stored as 32bits units whose order depends on the endianess. It is probably possible to do something better, taking advantage of cogl and the GL using the actual component order, but for now it is easier to use the GDK utility to convert the cairo surface. https://bugzilla.gnome.org/show_bug.cgi?id=693931 --- diff --git a/src/shell-screenshot.c b/src/shell-screenshot.c index 924713fdb..c354612c5 100644 --- a/src/shell-screenshot.c +++ b/src/shell-screenshot.c @@ -183,22 +183,19 @@ write_screenshot_thread (GSimpleAsyncResult *result, else { GdkPixbuf *pixbuf; - pixbuf = gdk_pixbuf_new_from_data (cairo_image_surface_get_data (screenshot_data->image), - GDK_COLORSPACE_RGB, - TRUE, - 8, - cairo_image_surface_get_width (screenshot_data->image), - cairo_image_surface_get_height (screenshot_data->image), - cairo_image_surface_get_stride (screenshot_data->image), - NULL, - NULL); + + pixbuf = gdk_pixbuf_get_from_surface (screenshot_data->image, + 0, 0, + cairo_image_surface_get_width (screenshot_data->image), + cairo_image_surface_get_height (screenshot_data->image)); + if (gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, NULL, "tEXt::Software", "gnome-screenshot", NULL)) status = CAIRO_STATUS_SUCCESS; else status = CAIRO_STATUS_WRITE_ERROR; - g_clear_object (&pixbuf); + g_object_unref (pixbuf); }